package com.demo.generics.xianzhi;

/**
 * @Description:
 * @Author: xiangty
 * @Date: 2018-07-24
 */
public class Policeman<T extends Weapon> {

    public void fankong(T wq) {
        System.out.println("警察手持" + wq + "反恐");
    }

    public static void main(String[] args){
        //Integer 不是Weapon的子类,所以不能用Policeman<Integer> 这样的
//        Policeman<Integer> p1 = new Policeman<Integer>();
//        p1.fankong(123);

        Policeman<Gun> policeman = new Policeman<Gun>();
        policeman.fankong(new Gun());
        //不能用
//        policeman.fankong(new Weapon());

        Policeman<Weapon> policeman1 = new Policeman<Weapon>();
        //可以用
//        policeman1.fankong(new Gun());
        policeman1.fankong(new Weapon());

    }

}
